<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<form class="layui-form white-bg" style="padding: 10px" action=""
		lay-filter="example">
		<fieldset class="layui-elem-field layui-field-title site-title">
			<legend>
				<a name="fixbar">课程评价</a>
			</legend>
		</fieldset>

		<div style="text-align: center; width: 100%">
			<div class="layui-form">
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label" style="width: 100px">请选择课程：</label>
						<div class="layui-input-inline">
							<select name="student" lay-verify="required">
								<option value="0">三个代表</option>
								<option value="1">一带一路</option>
								<option value="2">科学发展观</option>
							</select>
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label" style="width: 100px">请选择课时：</label>
						<div class="layui-input-inline">
							<select name="student" lay-verify="required">
								<option value=""></option>
								<option value="0">第一节课</option>
								<option value="1">第二节课</option>
								<option value="2">第三节课</option>
							</select>
						</div>
					</div>
				</div>
			</div>
		</div>
		<table class="layui-table">
			<thead>
				<tr>
					<th width="15%">讲师</th>
					<th width="30%">课程</th>
					<th width="20%">简评</th>
					<th width="20%" id="rateTH">评分</th>
					<th width="20%">操作</th>
				</tr>
			</thead>
			<tbody id="skpj_body">
			</tbody>
		</table>

	</form>
</body>
<script>
    $(function(){
        layui.use('form', function(){
            var form = layui.form;
            form.on('select', function(data){
                changeSKPJ();
            });
        });
    });

    function changeSKPJ(){
        var datas = [
			{"teacher":"张三", "course": "政治课1", "comment": "讲的很好1", "rate": 1, "rateObj": {"info":"11111"}},
            {"teacher":"张三", "course": "政治课2", "comment": "讲的很好2", "rate": 0, "rateObj": {"info":""}},
            {"teacher":"张三", "course": "政治课3", "comment": "讲的很好3", "rate": 0, "rateObj": {"info":"33333"}},
            {"teacher":"张三", "course": "政治课4", "comment": "讲的很好4", "rate": 0, "rateObj": {"info":""}},
            {"teacher":"张三", "course": "政治课5", "comment": "讲的很好5", "rate": 0, "rateObj": {"info":"4444"}},
            {"teacher":"张三", "course": "政治课6", "comment": "讲的很好6", "rate": 0, "rateObj": {"info":"55555"}},
		];
        var lines = datas.length;
        var html = "";
        layui.use(['rate'], function(){
            var rate = layui.rate;
            if(lines > 0){
                if(datas[0].rate ==0){
                    $("#rateTH").hide();
				}
			}
            for(var i=0;i<lines;i++){
                var arr_key = Math.floor(Math.random()*4);
                var oneObj = datas[i];
                var ops_str = "";
                html += "<tr>";
                html += "<th>"+oneObj.teacher+"</th>";
                html += "<th>"+oneObj.course+"</th>";
                html += "<th>"+oneObj.comment+"</th>";
                if(datas[0].rate !=0) {
                    html += "<th><div id='rate_" + i + "'></div></th>";
                }
                if(oneObj.rateObj.info.length > 0){
                    ops_str = "已评价 查看";
				}else {
                    ops_str = "请评价"
				}
                html += "<th><a href='#'>"+ops_str+"</a></th>";
				html += "</tr>"
			}
            $("#skpj_body").empty();
            $("#skpj_body").append(html);
            for(var j=0;j<lines;j++){
                rate.render({
                    elem: '#rate_'+j,
                    value: datas[j].rate,
                    readonly: true
                });
            }
		});
        /*
        layui.use(['rate'], function(){
            var rate = layui.rate;
            var name = ["张三", "李四", "王五", "Hello Kitty"];
            var arr = ["讲的很好，内容详细", "一般般吧，可以接受", "讲的不够具体", "讲的没大听懂"];
            var html = "";
            for(var i=0;i<name.length;i++){
                var arr_key = Math.floor(Math.random()*4);
                html += "<tr>";
                html += "<th>"+name[i]+"</th>";
                html += "<th>"+arr[arr_key]+"</th>";
                html += "<th><div id='rate_"+i+"'></div></th>";
                html += "<th><div id='ops_\"+i+\"'></th>";
                html += "</tr>";
            }
            $("#skpj_body").empty();
            $("#skpj_body").append(html);
            for(var j=0;j<name.length;j++){
                rate.render({
                    elem: '#rate_'+j,
                    value: Math.floor(Math.random()*5 + 1),
                    readonly: true
                });
                $("#")
            }
        });
        */
    }
</script>
</html>